/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.view;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;import com.model.Anggota;
import com.model.Perpustakaan;
import com.model.Pinjaman;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class PanelTambahAnggota_2 extends JPanel {
     private JLabel labelKodeAnggota ;
     private JTextField textKodeAnggota ;
     private JLabel labelNama ;
     private JTextField textNama ;
     private JButton tombolSimpan ;
     private JButton tombolBatal ;


         public PanelTambahAnggota_2 (){
         this.setSize(400,300);
         setLayout(null);

         labelKodeAnggota =new JLabel("Nama Anggota ");
         labelKodeAnggota.setBounds(50, 50, 150, 40);
         add(labelKodeAnggota);

          textKodeAnggota=new JTextField(20);
          textKodeAnggota.setBounds(150, 60, 150, 20);
          add(textKodeAnggota);

         labelNama  =new JLabel("Kode Anggota ");
         labelNama .setBounds(50, 80, 150, 40);
         add(labelNama);

         textNama=new JTextField(20);
         textNama.setBounds(150, 90, 150, 20);
         add(textNama);

            tombolSimpan = new JButton("SIMPAN ");
        tombolSimpan.setBounds(100, 150, 100, 20);
        add(tombolSimpan);
        tombolSimpan.addActionListener(new ActionListener () {
            public void actionPerformed(ActionEvent e) {
                tombolSimpanAction();
            }
        });

        tombolBatal = new JButton ("Batal");
        tombolBatal.setBounds(290, 280, 110, 30);
        add(tombolBatal);
        tombolBatal.addActionListener(new ActionListener () {
            public void actionPerformed(ActionEvent e) {
                tombolBatalAction();
            }
        });

        setVisible(true);
    }
    public void tombolSimpanAction() {
        Anggota agg = new Anggota();
        try {
            agg.setIdAnggota(textKodeAnggota.getText());
        } catch (Exception ex) {
            Logger.getLogger(PanelTambahAnggota.class.getName()).log(Level.SEVERE, null, ex);
        }
        agg.setNama(textNama.getText());
        Perpustakaan.tambahAnggota(agg);
        JOptionPane.showMessageDialog( this,"Id Anggota : "+agg.getIdAnggota() +
                                          "\nNama       : "+agg.getNama());
    }
    public void tombolBatalAction() {
        System.exit(0);

    }
}
